/*    */ package com.zimbra.cs.mime.handler;
/*    */ 
/*    */ import com.zimbra.common.util.ByteUtil;
/*    */ import com.zimbra.cs.convert.AttachmentInfo;
/*    */ import com.zimbra.cs.mime.MimeHandler;
/*    */ import com.zimbra.cs.mime.MimeHandlerException;
/*    */ import com.zimbra.cs.mime.MimeHandlerManager;
/*    */ import java.io.InputStream;
/*    */ import javax.activation.DataSource;
/*    */ import javax.mail.internet.InternetHeaders;
/*    */ import org.apache.lucene.document.Document;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class MessageRFC822Handler
/*    */   extends MimeHandler
/*    */ {
/*    */   protected boolean runsExternally()
/*    */   {
/* 45 */     return false;
/*    */   }
/*    */   
/*    */ 
/*    */ 
/*    */   public void addFields(Document doc) {}
/*    */   
/*    */ 
/*    */ 
/*    */   protected String getContentImpl()
/*    */     throws MimeHandlerException
/*    */   {
/* 57 */     DataSource ds = getDataSource();
/* 58 */     if (ds == null) {
/* 59 */       return null;
/*    */     }
/* 61 */     InputStream is = null;
/* 62 */     String content = null;
/*    */     try {
/* 64 */       is = ds.getInputStream();
/* 65 */       if (is == null) {
/* 66 */         return null;
/*    */       }
/* 68 */       InternetHeaders headers = new InternetHeaders(is);
/* 69 */       String[] subject = headers.getHeader("Subject");
/* 70 */       if ((subject == null) || (subject.length == 0) || (subject[0] == null)) {
/* 71 */         return null;
/*    */       }
/* 73 */       int maxLength = MimeHandlerManager.getIndexedTextLimit();
/* 74 */       if (subject[0].length() > maxLength) {
/* 75 */         content = subject[0].substring(0, maxLength);
/*    */       } else {
/* 77 */         content = subject[0];
/*    */       }
/*    */     } catch (Exception e) {
/* 80 */       throw new MimeHandlerException(e);
/*    */     } finally {
/* 82 */       ByteUtil.closeStream(is);
/*    */     }
/*    */     
/* 85 */     return content;
/*    */   }
/*    */   
/*    */   public boolean doConversion()
/*    */   {
/* 90 */     return false;
/*    */   }
/*    */   
/*    */   public String convert(AttachmentInfo doc, String baseURL)
/*    */   {
/* 95 */     throw new IllegalStateException("no need to convert message/rfc822 content");
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/mime/handler/MessageRFC822Handler.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */